<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="stable/static/css/site.css" rel="stylesheet" type="text/css">
    <link href="stable/static/css/print.css" rel="stylesheet" type="text/css" media="print">
    <link href="stable/static/css/prettify.css" rel="stylesheet" type="text/css">
    <link href="//www.google.com/images/icons/product/chrome-16.png" rel="icon" type="image/ico">
    <title>Permission Warnings - chrome插件中文开发文档(非官方)</title>
  </head>
  <body>
    <a id="top"></a>
    <div id="header">{Header content}</div>
    <a id="gc-topnav-anchor"></a>
    <div id="gc-topnav">
      <h1>Google Chrome Extensions</h1>
      <ul id="home" class="gc-topnav-tabs">
        <li id="home_link">
          <a href="index.html" title="Google Chrome Extensions home page"><div>Home</div></a>
        </li>
        <li id="docs_link">
          <a href="docs.html" title="Official Google Chrome Extensions documentation"><div>Docs</div></a>
        </li>
        <li id="faq_link">
          <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions"><div>FAQ</div></a>
        </li>
        <li id="samples_link">
          <a href="samples.html" title="Sample Extensions (with source code)"><div>Samples</div></a>
        </li>
        <li id="group_link">
          <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum"><div>Group</div></a>
        </li>
        <li id="so_link">
          <a href="http://stackoverflow.com/questions/tagged/google-chrome-extension" title="[google-chrome-extension] tag on Stack Overflow"><div>Questions?</div></a>
        </li>
      </ul>
    </div>
    <div id="gc-container">
      <div id="gc-sidebar">
        <ul 
            class="level1 ">
          <li class="level2">
                <a href="getstarted.html" class="level2 ">Getting Started</a>
          </li>
          <li class="level2">
                <a href="overview.html" class="level2 ">Overview</a>
          </li>
          <li class="level2">
                <a href="whats_new.html" class="level2 ">What's New?</a>
          </li>
          <li class="level2">
                <a href="devguide.html" class="level2 ">Developer's Guide</a>
              <ul 
                  class="level2 ">
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Browser UI</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="browserAction.html" class="level4 ">Browser Actions</a>
                      </li>
                      <li class="level4">
                            <a href="contextMenus.html" class="level4 ">Context Menus</a>
                      </li>
                      <li class="level4">
                            <a href="notifications.html" class="level4 ">Desktop Notifications</a>
                      </li>
                      <li class="level4">
                            <a href="omnibox.html" class="level4 ">Omnibox</a>
                      </li>
                      <li class="level4">
                            <a href="options.html" class="level4 ">Options Pages</a>
                      </li>
                      <li class="level4">
                            <a href="override.html" class="level4 ">Override Pages</a>
                      </li>
                      <li class="level4">
                            <a href="pageAction.html" class="level4 ">Page Actions</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Browser Interaction</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="bookmarks.html" class="level4 ">Bookmarks</a>
                      </li>
                      <li class="level4">
                            <a href="cookies.html" class="level4 ">Cookies</a>
                      </li>
                      <li class="level4">
                            <a href="devtools.html" class="level4 ">Developer Tools</a>
                      </li>
                      <li class="level4">
                            <a href="events.html" class="level4 ">Events</a>
                      </li>
                      <li class="level4">
                            <a href="history.html" class="level4 ">History</a>
                      </li>
                      <li class="level4">
                            <a href="management.html" class="level4 ">Management</a>
                      </li>
                      <li class="level4">
                            <a href="tabs.html" class="level4 ">Tabs</a>
                      </li>
                      <li class="level4">
                            <a href="windows.html" class="level4 ">Windows</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Implementation</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="a11y.html" class="level4 ">Accessibility</a>
                      </li>
                      <li class="level4">
                            <a href="event_pages.html" class="level4 ">Event Pages</a>
                      </li>
                      <li class="level4">
                            <a href="contentSecurityPolicy.html" class="level4 ">Content Security Policy</a>
                      </li>
                      <li class="level4">
                            <a href="content_scripts.html" class="level4 ">Content Scripts</a>
                      </li>
                      <li class="level4">
                            <a href="xhr.html" class="level4 ">Cross-Origin XHR</a>
                      </li>
                      <li class="level4">
                            <a href="i18n.html" class="level4 ">Internationalization</a>
                      </li>
                      <li class="level4">
                            <a href="messaging.html" class="level4 ">Message Passing</a>
                      </li>
                      <li class="level4">
                            <a href="permissions.html" class="level4 ">Optional Permissions</a>
                      </li>
                      <li class="level4">
                            <a href="npapi.html" class="level4 ">NPAPI Plugins</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Finishing</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="hosting.html" class="level4 ">Hosting</a>
                      </li>
                      <li class="level4">
                            <a href="external_extensions.html" class="level4 ">Other Deployment Options</a>
                      </li>
                    </ul>
                </li>
              </ul>
          </li>
          <li class="level2">
                <a href="tutorials.html" class="level2 ">Tutorials</a>
              <ul 
                  class="level2 ">
                <li class="level3">
                      <a href="tut_migration_to_manifest_v2.html" class="level3 ">Manifest V2</a>
                </li>
                <li class="level3">
                      <a href="tut_debugging.html" class="level3 ">Debugging</a>
                </li>
                <li class="level3">
                      <a href="tut_analytics.html" class="level3 ">Google Analytics</a>
                </li>
                <li class="level3">
                      <a href="tut_oauth.html" class="level3 ">OAuth</a>
                </li>
              </ul>
          </li>
          <li class="level2">
                <span class="level2">Reference</span>
              <ul 
                  class="level2 ">
                <li class="level3">
                    <a class="button level3">
                      <span class="level3">Formats</span>
                      <div class="toggleIndicator level3"></div>
                    </a>
                    <ul toggleable
                        class="level3 hidden">
                      <li class="level4">
                            <a href="manifest.html" class="level4 ">Manifest Files</a>
                      </li>
                      <li class="level4">
                            <a href="match_patterns.html" class="level4 ">Match Patterns</a>
                      </li>
                    </ul>
                </li>
                <li class="level3">
                      <a  class="level3 selected">Permission Warnings</a>
                </li>
                <li class="level3">
                      <a href="api_index.html" class="level3 ">chrome.* APIs</a>
                </li>
                <li class="level3">
                      <a href="api_other.html" class="level3 ">Other APIs</a>
                </li>
              </ul>
          </li>
          <li class="level2">
                <span class="level2">More</span>
              <ul 
                  class="level2 ">
                <li class="level3">
                      <a href="http://code.google.com/chrome/webstore/docs/index.html" class="level3 ">Chrome Web Store</a>
                </li>
                <li class="level3">
                      <a href="http://code.google.com/chrome/apps/docs/developers_guide.html" class="level3 ">Hosted Apps</a>
                </li>
                <li class="level3">
                      <a href="themes.html" class="level3 ">Themes</a>
                </li>
              </ul>
          </li>
        </ul>
      </div>
      <div id="gc-pagecontent">
        <h1 class="page_title">Permission Warnings</h1>
        <div id="toc">
          <h2>Contents</h2>
          <ol>
            <li>
              <a href=#examples> Examples of permission warnings </a>
            </li>
            <li>
              <a href=#warnings> Warnings and their triggers </a>
            </li>
            <li>
              <a href=#nowarning> Permissions that don't cause warnings </a>
            </li>
            <li>
              <a href=#test> Testing permission warnings </a>
            </li>
            <li>
              <a href=#api>API</a>
            </li>
          </ol>
        </div>




<!--
NOTE: When this doc is updated, the online help should also be updated:
http://www.google.com/support/chrome_webstore/bin/answer.py?hl=en&answer=186213

We should periodically look at
http://src.chromium.org/viewvc/chrome/trunk/src/chrome/app/generated_resources.grd?view=markup
to make sure that we're covering all messages. Search for
IDS_EXTENSION_PROMPT_WARNING
(e.g. IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY).
-->

<p>
To use most chrome.* APIs and extension capabilities,
your extension must declare its intent in the
<a href="manifest.html">manifest</a>,
often in the "permissions" field.
Some of these declarations
result in a warning when
a user installs your extension.
</p>

<p>
When you autoupdate your extension,
the user might see another warning
if the extension requests new permissions.
These new permissions might be new APIs that your extension uses,
or they might be new websites
that your extension needs access to.
</p>


<h2 id="examples"> Examples of permission warnings </h2>

<p>
Here's a typical dialog
that a user might see when installing an extension:
</p>

<img src="stable/static/images/perms-hw1.png"
  width="410" height="193"
  alt="Permission warning: 'It can: Access your data on api.flickr.com'"
  />

<p>
The warning about access to data on api.flickr.com
is caused by the following lines
in the extension's manifest:
</p>

<pre>
"permissions": [
  <b>"http://api.flickr.com/"</b>
],
</pre>

<p class="note">
<b>Note:</b>
You don't see permission warnings when
you load an unpacked extension.
You get permission warnings only when you install an extension
from a <code>.crx</code> file.
</p>

<p>
If you add a permission to the extension when you autoupdate it,
the user might see a new permission warning.
For example,
assume you add a new site and the "tabs" permission
to the previous example:
</p>

<pre>
"permissions": [
  "http://api.flickr.com/",
  <b>"http://*.flickr.com/",
  "tabs"</b>
],
</pre>

<p>
When the extension autoupdates,
the increased permissions
cause the extension to be disabled
until the user re-enables it.
Here's the warning the user sees:
</p>

<img src="stable/static/images/perms-hw2-disabled.png"
  width="814" height="30"
  alt="Warning text: 'The newest version of the extension Hello World requires more permissions, so it has been disabled. [Re-enable].'"
  />

<p>
Clicking the Re-enable button
brings up the following warning:
</p>

<img src="stable/static/images/perms-hw2.png"
  width="412" height="220"
  alt="Permission warning: 'It can: Access your data on api.flickr.com and flickr.com; Read and modify your browsing history'"
  />


<h2 id="warnings"> Warnings and their triggers </h2>

<p>
It can be surprising when adding a permission such as "tabs"
results in the seemingly unrelated warning
that the extension can access your browsing activity.
The reason for the warning is that
although the <code>chrome.tabs</code> API
might be used only to open new tabs,
it can also be used to see the URL that's associated
with every newly opened tab
(using their <a href="tabs.html#type-Tab">Tab</a> objects).
</p>

<p class="note">
<b>Note:</b>
As of Google Chrome 7,
you no longer need to specify the "tabs" permission
just to call <code>chrome.tabs.create()</code>
or <code>chrome.tabs.update()</code>.
</p>

<p>
The following table lists the warning messages
that users can see,
along with the manifest entries
that trigger them.
</p>

<p>
<table>
<tr>
  <th>Warning&nbsp;message</th> <th>Manifest&nbsp;entry&nbsp;that&nbsp;causes&nbsp;it</th> <th>Notes</th>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_FULL_ACCESS -->
    Access all data on your computer and the websites you visit
  </td>
  <td>
    "plugins"
  </td>
  <td>
    The "plugins" permission is required by
    <a href="npapi.html">NPAPI plugins</a>.
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_BOOKMARKS -->
    Read and modify your bookmarks
  </td>
  <td>
    "bookmarks" permission
  </td>
  <td>
    The "bookmarks" permission is required by the
    <a href="bookmarks.html"><code>chrome.bookmarks</code></a> module.
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_BROWSING_HISTORY -->
    Read and modify your browsing history
  </td>
  <td>
    <!-- HasEffectiveBrowsingHistoryPermission -->
     "history" permission
  </td>
  <td>
    <p>
      The "history" permission is required by
      <a href="history.html"><code>chrome.history</code></a>.
    </p>
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_TABS -->
    Access your tabs and browsing activity
  </td>
  <td>
    <!-- HasEffectiveBrowsingHistoryPermission -->
    Any of the following:
    <ul>
      <li> "tabs" permission </li>
      <li> "webNavigation" permission </li>
    </ul>
  </td>
  <td>
    <p>
      The "tabs" permission is required by the
      <a href="tabs.html"><code>chrome.tabs</code></a> and
      <a href="windows.html"><code>chrome.windows</code></a> modules.
    </p>
    <p>
      The "webNavigation" permission is required by the
      <a href="webNavigation.html"><code>chrome.webNavigation</code></a> module.
    </p>
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_CONTENT_SETTINGS -->
    Manipulate settings that specify whether websites can use features such as cookies, JavaScript, and plug-ins
  </td>
  <td>
    <!-- HasEffectiveBrowsingHistoryPermission -->
     "contentSettings" permission
  </td>
  <td>
    <p>
      The "contentSettings" permission is required by
      <a href="contentSettings.html"><code>chrome.contentSettings</code></a>.
    </p>
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_ALL_HOSTS -->
    Access your data on all websites
  </td>
  <td>
    <!-- HasEffectiveAccessToAllHosts() -->
    Any of the following:
    <ul>
      <li> "debugger" permission </li>
      <li> "proxy" permission </li>
      <li> A match pattern in the "permissions" field
        that matches all hosts </li>
      <li> A&nbsp;"content_scripts" field with a "matches" entry
        that matches all hosts </li>
      <li> "devtools_page" </li>
    </ul>
  </td>
  <td>
    <p>
      The "debugger" permission is required by the experimental
      <a href="experimental.debugger.html">debugger</a> module.
    </p>

    <p>
      The "proxy" permission is required by the
      <a href="proxy.html"><code>chrome.proxy</code></a> module.
    </p>

    <p>
      Any of the following URLs match all hosts:
    </p>
    <ul>
      <li> <code>http://*/*</code> </li>
      <li> <code>https://*/*</code> </li>
      <li> <code>*://*/*</code> </li>
      <li> <code>&lt;all_urls&gt;</code> </li>
    </ul>
  </td>
</tr>
<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_?_HOST -->
    <!-- IDS_EXTENSION_PROMPT_WARNING_4_OR_MORE_HOSTS -->
    Access your data on <em>{list of websites}</em>
  </td>
  <td>
    A match pattern in the "permissions" field
    that specifies one or more hosts,
    but not all hosts
  </td>
  <td>
    <p>
    Up to 3 sites are listed by name.
    Subdomains aren't treated specially.
    For example, <code>a.com</code> and <code>b.a.com</code>
    are listed as different sites.
    </p>

    <p>
    On autoupdate,
    the user sees a permission warning
    if the extension adds or changes sites.
    For example, going from <code>a.com,b.com</code>
    to <code>a.com,b.com,c.com</code>
    triggers a warning.
    Going from <code>b.a.com</code>
    to <code>a.com</code>,
    or vice versa,
    also triggers a warning.
    </p>
  </td>
</tr>
<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_ALL_PAGES_CONTENT -->
    Access the content of pages you visit
  </td>
  <td>
    "pageCapture" permission
  </td>
  <td>
    The "pageCapture" permission is required by the
    <a href="pageCapture.html"><code>chrome.pageCapture</code></a> module.
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_MANAGEMENT -->
    Manage your apps, extensions, and themes
  </td>
  <td>
    "management" permission
  </td>
  <td>
    The "management" permission is required by the
    <a href="management.html"><code>chrome.management</code></a> module.
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_GEOLOCATION -->
    Detect your physical location
  </td>
  <td>
    "geolocation" permission
  </td>
  <td>
    Allows the extension to use the proposed HTML5
    <a href="http://dev.w3.org/geo/api/spec-source.html">geolocation API</a>
    without prompting the user for permission.
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_CLIPBOARD-->
    Access data you copy and paste
  </td>
  <td>
    "clipboardRead" permission
  </td>
  <td>
    Allows the extension to use the following editing commands with
    <code>document.execCommand()</code>:
    <ul>
      <li> <code>"copy"</code> </li>
      <li> <code>"cut"</code> </li>
    </ul>
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_PRIVACY-->
    Manipulate privacy-related settings
  </td>
  <td>
    "privacy" permission
  </td>
  <td>
    The "privacy" permission is required by the
    <a href="privacy.html"><code>chrome.privacy</code></a> module.
  </td>
</tr>

<tr>
  <td style="font-weight:bold">
    <!-- IDS_EXTENSION_PROMPT_WARNING_TTS_ENGINE-->
    Access all text spoken using synthesized speech
  </td>
  <td>
    "ttsEngine" permission
  </td>
  <td>
    The "ttsEngine" permission is required by the
    <a href="ttsEngine.html"><code>chrome.ttsEngine</code></a> module.
  </td>
</tr>
</table>
</p>


<h2 id="nowarning"> Permissions that don't cause warnings </h2>

<p>
The following permissions don't result in a warning:
</p>

<ul>
  <li>"browsingData"</li>
  <li>"chrome://favicon/"</li>
  <li>"clipboardWrite"</li>
  <li>"contextMenus"</li>
  <li>"cookies"</li>
  <li>"experimental"</li>
  <li>"idle"</li>
  <li>"notifications"</li>
  <li>"storage"</li>
  <li>"unlimitedStorage"</li>
  <li>"webRequest"</li>
  <li>"webRequestBlocking"</li>
</ul>

<h2 id="test"> Testing permission warnings </h2>

<p>
If you'd like to see exactly which warnings your users will get,
<a href="packaging.html">package your extension</a>
into a <code>.crx</code> file,
and install it.
</p>

<p>
To see the warnings users will get when your extension is autoupdated,
you can go to a little more trouble
and set up an autoupdate server.
To do this, first create an update manifest
and point to it from your extension,
using the "update_url" key
(see <a href="autoupdate.html">Autoupdating</a>).
Next, <a href="packaging.html">package the extension</a>
into a new <code>.crx</code> file,
and install the app from this <code>.crx</code> file.
Now, change the extension's manifest to contain the new permissions,
and <a href="packaging.html#update">repackage the extension</a>.
Finally, update the extension
(and all other extensions that have outstanding updates)
by clicking the <b>chrome://extensions</b> page's
<b>Update extensions now</b> button.
</p>

<h2 id="api">API</h2>

<p>
You can get a list of permission warnings for any manifest with
<a href="management.html#method-getPermissionWarnings">chrome.management.getPermissionWarnings()</a>.
</p>
      </div>
    </div>
  </body>
  <script>
    window.bootstrap = {
      api_names: [{"name":"alarms"},{"name":"bookmarks"},{"name":"browserAction"},{"name":"browsingData"},{"name":"commands"},{"name":"contentSettings"},{"name":"contextMenus"},{"name":"cookies"},{"name":"debugger"},{"name":"declarativeWebRequest"},{"name":"devtools.inspectedWindow"},{"name":"devtools.network"},{"name":"devtools.panels"},{"name":"downloads"},{"name":"events"},{"name":"extension"},{"name":"fileBrowserHandler"},{"name":"fontSettings"},{"name":"history"},{"name":"i18n"},{"name":"idle"},{"name":"input.ime"},{"name":"management"},{"name":"omnibox"},{"name":"pageAction"},{"name":"pageCapture"},{"name":"permissions"},{"name":"privacy"},{"name":"proxy"},{"name":"runtime"},{"name":"scriptBadge"},{"name":"storage"},{"name":"tabs"},{"name":"topSites"},{"name":"tts"},{"name":"ttsEngine"},{"name":"types"},{"name":"webNavigation"},{"name":"webRequest"},{"name":"webstore"},{"last":true,"name":"windows"}].concat(
          [{"name":"experimental.bluetooth"},{"name":"experimental.devtools.audits"},{"name":"experimental.devtools.console"},{"name":"experimental.discovery"},{"name":"experimental.identity"},{"name":"experimental.infobars"},{"name":"experimental.offscreenTabs"},{"name":"experimental.processes"},{"name":"experimental.record"},{"name":"experimental.speechInput"},{"name":"experimental.systemInfo.cpu"},{"name":"experimental.systemInfo.storage"},{"last":true,"name":"experimental.usb"}]),
      branchInfo: {"channels":[{"path":"stable","name":"Stable"},{"path":"dev","name":"Dev"},{"path":"beta","name":"Beta"},{"path":"trunk","name":"Trunk"}],"current":"stable","showWarning":false}
    };
  </script>
  <div id="gc-footer">
    <div class="text">
      <p>
        Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
        the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
        Attribution 3.0 License</a>, and code samples are licensed under the
        <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
      </p>
      <p>
        ©2012 Google
      </p>
      <script src="stable/static/js/branch.js" type="text/javascript"></script>
      <script src="stable/static/js/sidebar.js" type="text/javascript"></script>
      <script src="stable/static/js/prettify.js" type="text/javascript"></script>
      <script>
        (function() {
          // Auto syntax highlight all pre tags.
          var preElements = document.getElementsByTagName('pre');
          for (var i = 0; i < preElements.length; i++)
            preElements[i].classList.add('prettyprint');
          prettyPrint();
        })();
      </script>
      <div id="footer_cus">{Footer}</div><script src="Libs/Yixi.js"></script><script src="http://s9.cnzz.com/stat.php?id=4928336&web_id=4928336" language="JavaScript"></script>
  
    </div>
  </div>
</html>
